#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
map<string,int> name;
const int N=1e5+50;
int p[N];
int find(int x){
    return x==p[x]?x:p[x]=find(p[x]);
}
void unit(int x,int y){
    int fx=find(x);
    int fy=find(y);
    if(fx!=fy){
        p[fx]=fy;
    }
}
int n;
int o;
string s1,s2;
int main(void){
    while(~scanf("%d",&n)){
        int cnt=1;
        name.clear();
        memset(p,0,sizeof(p));
        for(int i=1;i<=n;i++){
            p[i]=i;
        }
        while(n--){
            cin >> o >> s1 >> s2;
            //查询是否同个集合的时候名字可能是第一次出现
            if(name.find(s1)==name.end()){
                name[s1]=cnt++;
            }
            if(name.find(s2)==name.end()){
                name[s2]=cnt++;
            }
            if(o==0){
                unit(name[s1],name[s2]);
            }
            else if(o==1){
                if(find(name[s1])==find(name[s2])){
                    printf("yes\n");
                }
                else{
                    printf("no\n");
                }
            }
        }
    }
    return 0;
}